#include "UI.hpp"

#include "referee.hpp"
#include "rtthread.h"
#include "stdlib.h"
#include "usart.h"
#include "supercap.hpp"
#include "chassis.hpp"
#include "gimbal.hpp"
#include "shoot.hpp"
#include "power_control.hpp"
#include "dr16.hpp"
#include "logic_thread.hpp"


/* 图形对象 */
ext_client_custom_graphic_delete_t graphic_delete;    /* 删除所有图形数据 */
ext_client_custom_graphic_single_t graphic_single;      /* 一个图形数据，圆或圆弧*/
ext_client_custom_graphic_double_t graphic_double;  /* 两个图形数据，车宽*/
ext_client_custom_graphic_five_t   graphic_target;    /* 五个图形数据，准心 */
ext_client_custom_character_t      graphic_character; /* 单个图形数据，画字符 */

extern uint8_t RefereeSendBuf[128]; /* 发送到裁判系统的数据 */
extern uint8_t *tem_spinning;
extern uint8_t *tem_aimbot;
extern uint8_t *tem_supercap;

static uint8_t Show_ = 0;
/**
 * @brief 准心图形对象操作函数，第一图层，图形索引：GRAPIC_TARGET_X, GRAPIC_TARGET_Y，坐标在target结构体中调用
 *
 * @param operation_tpye 操作类型：1新增图形，2修改图形
 * @param xy x,y坐标
 * @return void
 */
void Grapic_Target(int operation_tpye, int x, int y) {
    graphic_target.grapic_data_struct[0].graphic_name[0] = GRAPIC_TARGET_Y;
    graphic_target.grapic_data_struct[0].operate_tpye    = operation_tpye; /* 1新增图形 */
    graphic_target.grapic_data_struct[0].graphic_tpye    = 0;              /* 0直线 */
    graphic_target.grapic_data_struct[0].layer           = 1;              /* 第1图层 */
    graphic_target.grapic_data_struct[0].color           = 1;              /* 1：黄色 */
    graphic_target.grapic_data_struct[0].width           = 2;              /* 线宽 */
    graphic_target.grapic_data_struct[0].start_x         = x;
    graphic_target.grapic_data_struct[0].end_x           = x;
    graphic_target.grapic_data_struct[0].start_y         = y + 25;
    graphic_target.grapic_data_struct[0].end_y           = y - 125;

    graphic_target.grapic_data_struct[1].graphic_name[0] = GRAPIC_TARGET_X1;
    graphic_target.grapic_data_struct[1].operate_tpye    = operation_tpye; /* 1新增图形 */
    graphic_target.grapic_data_struct[1].graphic_tpye    = 0;              /* 0直线 */
    graphic_target.grapic_data_struct[1].layer           = 1;              /* 第1图层 */
    graphic_target.grapic_data_struct[1].color           = 1;              /* 1：黄色 */
    graphic_target.grapic_data_struct[1].width           = 2;              /* 线宽 */
    graphic_target.grapic_data_struct[1].start_x         = x - 25;
    graphic_target.grapic_data_struct[1].end_x           = x + 25;
    graphic_target.grapic_data_struct[1].start_y         = y;
    graphic_target.grapic_data_struct[1].end_y           = y;

    graphic_target.grapic_data_struct[2].graphic_name[0] = GRAPIC_TARGET_X2;
    graphic_target.grapic_data_struct[2].operate_tpye    = operation_tpye; /* 1新增图形 */
    graphic_target.grapic_data_struct[2].graphic_tpye    = 0;              /* 0直线 */
    graphic_target.grapic_data_struct[2].layer           = 1;              /* 第1图层 */
    graphic_target.grapic_data_struct[2].color           = 1;              /* 1：黄色 */
    graphic_target.grapic_data_struct[2].width           = 2;              /* 线宽 */
    graphic_target.grapic_data_struct[2].start_x         = x - 20;
    graphic_target.grapic_data_struct[2].end_x           = x + 20;
    graphic_target.grapic_data_struct[2].start_y         = y - 30;
    graphic_target.grapic_data_struct[2].end_y           = y - 30;

    graphic_target.grapic_data_struct[3].graphic_name[0] = GRAPIC_TARGET_X3;
    graphic_target.grapic_data_struct[3].operate_tpye    = operation_tpye; /* 1新增图形 */
    graphic_target.grapic_data_struct[3].graphic_tpye    = 0;              /* 0直线 */
    graphic_target.grapic_data_struct[3].layer           = 1;              /* 第1图层 */
    graphic_target.grapic_data_struct[3].color           = 1;              /* 1：黄色 */
    graphic_target.grapic_data_struct[3].width           = 2;              /* 线宽 */
    graphic_target.grapic_data_struct[3].start_x         = x - 20;
    graphic_target.grapic_data_struct[3].end_x           = x + 20;
    graphic_target.grapic_data_struct[3].start_y         = y - 60;
    graphic_target.grapic_data_struct[3].end_y           = y - 60;

    graphic_target.grapic_data_struct[4].graphic_name[0] = GRAPIC_TARGET_X4;
    graphic_target.grapic_data_struct[4].operate_tpye    = operation_tpye; /* 1新增图形 */
    graphic_target.grapic_data_struct[4].graphic_tpye    = 0;              /* 0直线 */
    graphic_target.grapic_data_struct[4].layer           = 1;              /* 第1图层 */
    graphic_target.grapic_data_struct[4].color           = 1;              /* 1：黄色 */
    graphic_target.grapic_data_struct[4].width           = 2;              /* 线宽 */
    graphic_target.grapic_data_struct[4].start_x         = x - 20;
    graphic_target.grapic_data_struct[4].end_x           = x + 20;
    graphic_target.grapic_data_struct[4].start_y         = y - 90;
    graphic_target.grapic_data_struct[4].end_y           = y - 90;
}

/**
 * @brief 车宽图形函数，第三图层
 *
 * @param operation_tpye 操作类型：1新增图形，2修改图形
 * @return void
 */
void Grapic_CarWidth(int operation_tpye) {
    graphic_double.grapic_data_struct[0].graphic_name[0] = GRAPIC_CAR_LEFT;
    graphic_double.grapic_data_struct[0].operate_tpye    = operation_tpye; /* 1新增图形 */
    graphic_double.grapic_data_struct[0].graphic_tpye    = 0;              /* 0直线 */
    graphic_double.grapic_data_struct[0].layer           = 3;              /* 第1图层 */
    graphic_double.grapic_data_struct[0].color           = 1;              /* 1：黄色 */
    graphic_double.grapic_data_struct[0].width           = 2;              /* 线宽 */
    graphic_double.grapic_data_struct[0].start_x         = 530;
    graphic_double.grapic_data_struct[0].end_x           = 700;
    graphic_double.grapic_data_struct[0].start_y         = 0;
    graphic_double.grapic_data_struct[0].end_y           = 300;

    graphic_double.grapic_data_struct[1].graphic_name[0] = GRAPIC_CAR_RIGHT;
    graphic_double.grapic_data_struct[1].operate_tpye    = operation_tpye; /* 1新增图形 */
    graphic_double.grapic_data_struct[1].graphic_tpye    = 0;              /* 0直线 */
    graphic_double.grapic_data_struct[1].layer           = 3;              /* 第1图层 */
    graphic_double.grapic_data_struct[1].color           = 1;              /* 1：黄色 */
    graphic_double.grapic_data_struct[1].width           = 2;              /* 线宽 */
    graphic_double.grapic_data_struct[1].start_x         = 1180;
    graphic_double.grapic_data_struct[1].end_x           = 1350;
    graphic_double.grapic_data_struct[1].start_y         = 300;
    graphic_double.grapic_data_struct[1].end_y           = 0;

}
/**
 * @brief 电容条图形对象操作函数，第3图层
 *
 * @param operation_tpye 操作类型：1新增图形，2修改图形
 * @param xy x,y坐标
 * @return void
 */

void Grapic_Singleline(int operation_tpye,int x1, int x2,int y1, int y2) {
    graphic_single.grapic_data_struct.graphic_name[0] = GRAPIC_CHARACTER_SUPERCAPLINE;
    graphic_single.grapic_data_struct.operate_tpye    = operation_tpye; /* 1新增图形 */
    graphic_single.grapic_data_struct.graphic_tpye    = 0;              /* 0直线 */
    graphic_single.grapic_data_struct.layer           = 3;              /* 第3图层 */
    graphic_single.grapic_data_struct.color           = cyan;         
    graphic_single.grapic_data_struct.width           = 52;              /* 线宽 */
    graphic_single.grapic_data_struct.start_x         = x1;
    graphic_single.grapic_data_struct.end_x           = x2;
    graphic_single.grapic_data_struct.start_y         = y1;
    graphic_single.grapic_data_struct.end_y           = y2;
}
/**
 * @brief 字符图形对象操作函数，第二图层，图形索引：GRAPIC_CHARACTER_1
 *
 * @param operation_tpye 操作类型：1新增图形，2修改图形
 * @param char_data      字符数据
 * @param char_length    字符数据长度
 * @param xy             放置的x，y坐标
 * @param name           图形索引名称
 * @return void
 */
void Grapic_Character(int operation_tpye, char *char_data, int char_length, int x, int y, int name, int color) {
    graphic_character.grapic_data_struct.graphic_name[0] = name;
    graphic_character.grapic_data_struct.operate_tpye    = operation_tpye;
    graphic_character.grapic_data_struct.graphic_tpye    = 7; /* 7字符 */
    graphic_character.grapic_data_struct.layer           = 2;
    graphic_character.grapic_data_struct.color           = color;
    graphic_character.grapic_data_struct.width           = 2;  /* 线宽 */
    graphic_character.grapic_data_struct.start_angle     = 20; /* 字体大小,字体大小与线宽比例10:1 */
    graphic_character.grapic_data_struct.end_angle       = char_length; /* 字符长度 */
    graphic_character.grapic_data_struct.start_x         = x;
    graphic_character.grapic_data_struct.start_y         = y;

    rt_memset(graphic_character.data, 0, 30);
    rt_strncpy(reinterpret_cast<char *>(graphic_character.data), char_data, char_length);
}

/**
 * @brief 字符图形对象操作函数，第二图层，图形索引：GRAPIC_CHARACTER_1
 *
 * @param operation_tpye 操作类型：1新增图形，2修改图形
 * @param char_data      字符数据
 * @param char_length    字符数据长度
 * @param xy             放置的x，y坐标
 * @param name           图形索引名称
 * @return void
 */
void Grapic_Character_2(int operation_tpye, char *char_data, int char_length, int x, int y, int name, int color) {
    graphic_character.grapic_data_struct.graphic_name[0] = name;
    graphic_character.grapic_data_struct.operate_tpye    = operation_tpye;
    graphic_character.grapic_data_struct.graphic_tpye    = 7; /* 7字符 */
    graphic_character.grapic_data_struct.layer           = 4;
    graphic_character.grapic_data_struct.color           = color;
    graphic_character.grapic_data_struct.width           = 4;  /* 线宽 */
    graphic_character.grapic_data_struct.start_angle     = 30; /* 字体大小,字体大小与线宽比例10:1 */
    graphic_character.grapic_data_struct.end_angle       = char_length; /* 字符长度 */
    graphic_character.grapic_data_struct.start_x         = x;
    graphic_character.grapic_data_struct.start_y         = y;

    rt_memset(graphic_character.data, 0, 30);
    rt_strncpy(reinterpret_cast<char *>(graphic_character.data), char_data, char_length);
}

/**
* @brief 正圆函数，第四图层    
 *
 * @param operation_tpye 操作类型：1新增图形，2修改图形
 * @param char_data      字符数据
 * @param char_length    字符数据长度
 * @param xy             放置的x，y坐标
 * @param name           图形索引名称
 * @return void
 */
void Grapic_CircleFULL(int operation_tpye, int name, int x, int y, int r) {
    graphic_single.grapic_data_struct.graphic_name[0] = name;
    graphic_single.grapic_data_struct.operate_tpye    = operation_tpye;
    graphic_single.grapic_data_struct.graphic_tpye    = 2;  /* 2正圆 */
    graphic_single.grapic_data_struct.layer           = 4;  /* 第四图层 */
    graphic_single.grapic_data_struct.color           = yellow;
    graphic_single.grapic_data_struct.width           = 2;  /* 线宽 */
    graphic_single.grapic_data_struct.start_x         = x;  /* 圆心x坐标 */
    graphic_single.grapic_data_struct.start_y         = y;  /* 圆心y坐标 */
    graphic_single.grapic_data_struct.radius          = r;  /* 半径 */
}
/**
* @brief 圆弧函数，第四图层    
 *
 * @param operation_tpye 操作类型：1新增图形，2修改图形
 * @param char_data      字符数据
 * @param char_length    字符数据长度
 * @param xy             放置的x，y坐标
 * @param name           图形索引名称
 * @return void
 */
void Grapic_CircleArc(int operation_tpye, int name, int x, int y,int start_angle,int end_angle,int r,int color) {
    graphic_single.grapic_data_struct.graphic_name[0] = name;
    graphic_single.grapic_data_struct.operate_tpye    = operation_tpye;
    graphic_single.grapic_data_struct.graphic_tpye    = 4;  /* 4圆弧 */
    graphic_single.grapic_data_struct.layer           = 4;  /* 第四图层 */
    graphic_single.grapic_data_struct.color           = color;
	  graphic_single.grapic_data_struct.start_angle     = start_angle;
	  graphic_single.grapic_data_struct.end_angle       = end_angle;
    graphic_single.grapic_data_struct.width           = 6;  /* 线宽 */
    graphic_single.grapic_data_struct.start_x         = x;  /* 圆心x坐标 */
    graphic_single.grapic_data_struct.start_y         = y;  /* 圆心y坐标 */
//    graphic_single.grapic_data_struct.radius          = r;  /* 半径 */
		graphic_single.grapic_data_struct.end_x           = r; //x半轴长度 
	  graphic_single.grapic_data_struct.end_y           = r; //y半轴长度 
}

/**
* @brief 矩形函数，第四图层    
 *
 * @param operation_tpye 操作类型：1新增图形，2修改图形
 * @param char_data      字符数据
 * @param char_length    字符数据长度
 * @param xy             放置的x，y坐标
 * @param name           图形索引名称
 * @return void
 */
void Grapic_Rectangle(int operation_tpye, int name, int x1, int y1,int x2, int y2) {
    graphic_single.grapic_data_struct.graphic_name[0] = name;
    graphic_single.grapic_data_struct.operate_tpye    = operation_tpye;
    graphic_single.grapic_data_struct.graphic_tpye    = 1;  /* 1矩形 */
    graphic_single.grapic_data_struct.layer           = 4;  /* 第四图层 */
    graphic_single.grapic_data_struct.color           = cyan;
    graphic_single.grapic_data_struct.width           = 2;  /* 线宽 */
    graphic_single.grapic_data_struct.start_x         = x1;   
    graphic_single.grapic_data_struct.start_y         = y1;  
		graphic_single.grapic_data_struct.end_x           = x2; 
	  graphic_single.grapic_data_struct.end_y           = y2;  
}

/**
 * @brief 新增或修改矩形函数
 *
 * @param operation_tpye 操作类型：新增或修改，可选参数：AddGraphic, ModifyGraphic
 * @param xy坐标
 */
void UI::Rectangle(int operation_tpye, int start_x, int end_x,int start_y,int end_y) {
    int length;

		Grapic_Rectangle(operation_tpye, GRAPIC_Rectangle, start_x, start_y, end_x,end_y);
    length = Referee_ConfigFrameData(0x0101, &graphic_single, 15);
    HAL_UART_Transmit(&REFEREE_UART, RefereeSendBuf, length, 0xFFFF);
}

UI::UI(void){
		DeleteAllGraphic();
}




void UI::AddGraphic_all(){
	
		switch (Show_){
			case 0:	ui.Target(AddGraphic, 960, 620);break;
			case 1:	ui.Car_Width(AddGraphic);	break;
			case 2:	ui.BotLevel(AddGraphic, 0);break;
			case 3:	ui.CapVoltage(AddGraphic, 0);			break;
			case 4:	ui.friction_state(AddGraphic, 0);break;
			case 5:	ui.ChassisFace(AddGraphic, gimbal.get_yaw(),30);break;
			case 6:	ui.aimbot_state(AddGraphic, 0);break;
			case 7: ui.supercap_state(AddGraphic, 0);break;
			case 8: ui.deploy_state(AddGraphic, 0);break;
			case 9:	ui.Circle(AddGraphic,960,620,15);break;			
			case 10:ui.Rectangle(AddGraphic,1750,1800,500,800);break;
			
		}
	Show_++;
	Show_%=11;
}


/**
 * @brief 删除所有图形
 *
 */
void UI::DeleteAllGraphic(){
    int length;

    graphic_delete.operate_tpye = 2;
    length                      = Referee_ConfigFrameData(0x0100, &graphic_delete, 2);

    HAL_UART_Transmit(&REFEREE_UART, RefereeSendBuf, length, 0xFFFF);

}

/**
 * @brief 新增或修改准心坐标
 *
 * @param operation_tpye 操作类型：新增或修改，可选参数：AddGraphic, ModifyGraphic
 * @param xy 准心的xy坐标
 */
void UI::Target(int operation_tpye, int x, int y) {
    int length;

    Grapic_Target(operation_tpye, x, y);
    length = Referee_ConfigFrameData(0x0103, &graphic_target, 6 + 75);

    HAL_UART_Transmit(&REFEREE_UART, RefereeSendBuf, length, 0xFFFF);

}
/**
 * @brief 新增或修改瞄准圆
 *
 * @param operation_tpye 操作类型：新增或修改，可选参数：AddGraphic, ModifyGraphic
 * @param xy坐标
 */
void UI::Circle(int operation_tpye, int x, int y,int r) {
    int length;

		Grapic_CircleFULL(operation_tpye, GRAPIC_Circle, x, y, r);
    length = Referee_ConfigFrameData(0x0101, &graphic_single, 15);
    HAL_UART_Transmit(&REFEREE_UART, RefereeSendBuf, length, 0xFFFF);

}
///**
//* @brief 新增或修改机器人位置
// *
// * @param operation_tpye 操作类型：新增或修改，可选参数：AddGraphic, ModifyGraphic
// * @param xy坐标
// */
//void UI::Robot_pos(int operation_tpye, int x, int y) {
//    int length;

//		Grapic_CircleFULL(operation_tpye, GRAPIC_CHARACTER_Robotpos, x, y, 5);
//    length = Referee_ConfigFrameData(0x0101, &graphic_single, 15);
//    HAL_UART_Transmit(&REFEREE_UART, RefereeSendBuf, length, 0xFFFF);

//}
/**
 * @brief 新增或修改车宽线
 *
 * @param operation_tpye 操作类型：新增或修改，可选参数：AddGraphic, ModifyGraphic
 */
void UI::Car_Width(int operation_tpye) {
    int length;

    Grapic_CarWidth(operation_tpye);
    length = Referee_ConfigFrameData(0x0102, &graphic_double, 6 + 30);

    HAL_UART_Transmit(&REFEREE_UART, RefereeSendBuf, length, 0xFFFF);
}

/**
 * @brief 新增或修改超级电容电压字符
 *
 * @param operation_tpye 操作类型：新增或修改，可选参数：AddGraphic, ModifyGraphic
 * @param supercap_voltage 超级电容电压值
 */
void UI::CapVoltage(int operation_tpye, float supercap_voltage) {
    int  length;
    char str[10];

    rt_sprintf(str, "CAP:%4d", (int16_t)(supercap_voltage * 100));
    Grapic_Character_2(operation_tpye, str, sizeof(str), 1630, 850, GRAPIC_CHARACTER_SUPERCAP, cyan);
    length = Referee_ConfigFrameData(0x0110, &graphic_character, 15 + 30);
    HAL_UART_Transmit(&REFEREE_UART, RefereeSendBuf, length, 0xFFFF);
	
	
	
//		Grapic_Singleline(operation_tpye,1775,1775,500,850);
//    length = Referee_ConfigFrameData(0x0101, &graphic_single, 15);
//    HAL_UART_Transmit(&REFEREE_UART, RefereeSendBuf, length, 0xFFFF);
	
	
}

/**
 * @brief 新增或修改机器人等级UI
 *
 * @param operation_tpye 操作类型：新增或修改，可选参数：AddGraphic, ModifyGraphic
* @param level 机器人等级
 */
void UI::BotLevel(int operation_tpye, int level) {
    int  length;
    char str[20];

    rt_sprintf(str, "level:%2d",level);
    Grapic_Character(operation_tpye, str, sizeof(str), 20, 4900, GRAPIC_CHARACTER_BotLevel, white);
    length = Referee_ConfigFrameData(0x0110, &graphic_character, 15 + 30);

    HAL_UART_Transmit(&REFEREE_UART, RefereeSendBuf, length, 0xFFFF);
}

/**
 * @brief 新增或修改摩擦轮是否打开
 *
 * @param operation_tpye 操作类型：新增或修改，可选参数：AddGraphic, ModifyGraphic
 * @param is_chassis_spin 是否打开弹仓
 */
void UI::friction_state(int operation_type, uint8_t is_open) {
    int length;
    char str[25];
    
    if (is_open == 1 || is_open == 4) {
        rt_sprintf(str, "fric:  ON");
        Grapic_Character_2(operation_type, str, sizeof(str), 20, 600, GRAPIC_CHARACTER_FRICTION, amaranth);
    } else {
        rt_sprintf(str, "fric:  OFF");
        Grapic_Character_2(operation_type, str, sizeof(str), 20, 600, GRAPIC_CHARACTER_FRICTION, green);
    }
    length = Referee_ConfigFrameData(0x0110, &graphic_character, 15 + 30);
    HAL_UART_Transmit(&REFEREE_UART, RefereeSendBuf, length, 0xFFFF);
}

/**
 * @brief 新增或修改底盘小陀螺
 *
 * @param operation_tpye 操作类型：新增或修改，可选参数：AddGraphic, ModifyGraphic
 * @param yaw yaw轴角度 arc_length 弧长/2
 */
void UI::ChassisFace(int operation_tpye, int16_t yaw,int16_t arc_length) {
    int  length;
		uint32_t angle;
		int32_t start,end,temp;
		if (yaw < YAW_ZERO_DEGREE) {
				yaw = 8192 + yaw;
		}
	  angle=(uint32_t)((yaw-YAW_ZERO_DEGREE)/(8192 / 360.0F));
	

		start=angle-arc_length;
		end=angle+arc_length;
		if(start<0)start+=360;
		
		Grapic_CircleArc(operation_tpye,GRAPIC_CircleArc_1, 960, 540,start,end,350,white);
		length = Referee_ConfigFrameData(0x0101, &graphic_single, 15);
    HAL_UART_Transmit(&REFEREE_UART, RefereeSendBuf, length, 0xFFFF); 
		length = Referee_ConfigFrameData(0x0101, &graphic_single, 15);
    HAL_UART_Transmit(&REFEREE_UART, RefereeSendBuf, length, 0xFFFF); 
		
}


/**
 * @brief 新增或修改自瞄是否打开
 *
 * @param operation_tpye 操作类型：新增或修改，可选参数：AddGraphic, ModifyGraphic
 * @param is_open 是否打开自瞄
 */
void UI::aimbot_state(int operation_type, uint8_t is_open) {
    int length;
    char str[25];
    
    if (is_open) {
        rt_sprintf(str, "aimbot:ON");
        Grapic_Character(operation_type, str, sizeof(str), 20, 550, GRAPIC_CHARACTER_AIMBOT, amaranth);
    } else {
        rt_sprintf(str, "aimbot:OFF");
        Grapic_Character(operation_type, str, sizeof(str), 20, 550, GRAPIC_CHARACTER_AIMBOT, green);
    }
    length = Referee_ConfigFrameData(0x0110, &graphic_character, 15 + 30);
    HAL_UART_Transmit(&REFEREE_UART, RefereeSendBuf, length, 0xFFFF);
}
/**
 * @brief 新增或修改supercap是否打开
 *
 * @param operation_tpye 操作类型：新增或修改，可选参数：AddGraphic, ModifyGraphic
 * @param is_open 是否打开supercap
 */
void UI::supercap_state(int operation_type, uint8_t is_open) {
    int length;
    char str[25];
    
    if (is_open) {
        rt_sprintf(str, "power:ON");
        Grapic_Character(operation_type, str, sizeof(str), 260, 550, GRAPIC_CHARACTER_SUPERCAP_STATE, amaranth);
    } else {
        rt_sprintf(str, "power:OFF");
        Grapic_Character(operation_type, str, sizeof(str), 260, 550, GRAPIC_CHARACTER_SUPERCAP_STATE, green);
    }
    length = Referee_ConfigFrameData(0x0110, &graphic_character, 15 + 30);
    HAL_UART_Transmit(&REFEREE_UART, RefereeSendBuf, length, 0xFFFF);
}
/**
 * @brief 新增或修改deploy_mode是否打开
 *
 * @param operation_tpye 操作类型：新增或修改，可选参数：AddGraphic, ModifyGraphic
 * @param is_open 是否打开supercap
 */
void UI::deploy_state(int operation_type, bool is_open) {
    int length;
    char str[25];
    
    if (is_open==true) {
        rt_sprintf(str, "deploy:ON");
        Grapic_Character_2(operation_type, str, sizeof(str),20,700, GRAPIC_CHARACTER_DEPLOY, amaranth);
    } else {
        rt_sprintf(str, "deploy:OFF");
        Grapic_Character_2(operation_type, str, sizeof(str),20,700, GRAPIC_CHARACTER_DEPLOY, green);
    }
    length = Referee_ConfigFrameData(0x0110, &graphic_character, 15 + 30);
    HAL_UART_Transmit(&REFEREE_UART, RefereeSendBuf, length, 0xFFFF);
}

void UI::debug(void) {

//	rt_kprintf("%d\n",*tem_spinning);
//	rt_kprintf("%d\n",Show_ui);


}
